home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0514.ZIP
/
CRAYZ15.ARC
/
VDIDR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-08-01
|
6KB
|
153 lines
{ Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730 }
program main ;
{ Program: }
{ }
{ LINPACK SGEDI Test Driver. }
{ }
{ Version: Date: }
{ }
{ 1.5/TURBO Pascal 3.0 08/02/86 }
{ }
{ Description: }
{ }
{ Uses LINPACK SGECO to compute RCond for matrix }
{ A and LINPACK SGEDI to compute determinant and }
{ inverse of matrix A where A is set up as a }
{ Hilbert matrix of specified order using SYSGEN. }
{ Uses SGEFA and SGEDI to invert inverse to com- }
{ with original. }
{ }
{ Author: }
{ }
{ Adam Fritz }
{ 133 Main Street }
{ Afton, New York 13730 }
{ }
{-I DizZ.con CONSTANT Declarations }
{-I Dizz.typ TYPE Declarations }
{-I Dizz.var VARIABLE Declarations }
{$I CrayZ.con CONSTANT Declarations }
{$I Crayz.typ TYPE Declarations }
{$I Crayz.var VARIABLE Declarations }
i, j : integer ;
aaID : vARRAY ;
pID : vARRAY ;
{-I DizZ.pas Vector I/O Routines }
{$I DrivZ.pas Vector I/O Routines }
{-I CGen.pas Test System Generator }
{$I Hilgen.pas Test System Generator }
{-I VectScal.p MathPak (C) Routine Package }
{-I SkipVS.p MathPak (C) Routine Package }
{-I mpBLAS.pas MathPak (C) BLAS }
{$I BLAS.pas Basic Linear Algebra }
{$I vSGETP.pas Virtual Array Transpose }
{$I vSGEFA.pas LINPACK Factor }
{$I vSGEDI.pas LINPACK Determinant and }
{ Inverse }
{$I vOUT.pas Virtual Array Output }
{$I OUT.pas SICE Output Routine }
begin
{ Initialize }
writeln('LINPACK SGEDI Test Program, CrayZ Version 1.5.') ;
writeln ;
{ Get Order }
n := 0 ;
while (n < 1) or (n > lda) do begin
write('Order: ') ;
readln(n)
end ;
{ Allocate Original Matrix }
vCreate (aID,'aMATRIX.$$$',n) ;
{ Get Print Code }
write('Print Code: ') ;
readln (PrintCode) ;
{ Generate Test System }
SYSGEN (aID, lda, n, b) ;
if PrintCode > 0 then begin
writeln ;
writeln('Original System (by column):') ;
writeln ;
vOUT (aID, n) ;
OUT (b[1], lda, n, 1)
end ;
{ Allocate Copy Matrix }
vCreate (aaID,'aaMATRIX.$$$',n) ;
{ Fill Transpose Matrix. }
for i := 1 to n do
Aj[i] := 0.0 ;
for j := 1 to n do
VectorWrite (aaID,n,1,j,n,Aj) ;
{ Transpose Original }
vSGETP (aID, aaID, n) ;
if PrintCode > 0 then begin
writeln ;
writeln ('Transpose (by column):') ;
writeln ;
vOUT (aaID, n)
end ;
{ Factor Matrix }
vSGEFA (aID, lda, n, IPvt, InfoCode) ;
if PrintCode > 0 then begin
writeln ;
writeln('Factored Matrix (by column):') ;
writeln ;
vOUT (aID, n)
end ;
{ Compute Determinant and Inverse }
JobCode := 11 ;
vSGEDI (aID, lda, n, IPvt, Det, Work, JobCode) ;
if PrintCode > 0 then begin
writeln ;
writeln('Inverse (by column):') ;
writeln ;
vOUT (aID, n) ;
writeln('Determinant: ',Det[1]:14:8,'E',Det[2]:3:0)
end ;
{ Allocate Product Matrix }
vCreate (pID,'pMATRIX.$$$',n) ;
{ Original Times Inverse }
for j := 1 to n do begin
iAj := VectorRead (aaID,n,1,j,n,Aj) ;
for i := 1 to n do begin
iAi := VectorRead (aID,n,1,i,n,Ai) ;
Ak[i] := SDOT (n, Aj[1], 1, Ai[1], 1)
end ;
VectorWrite (pID,n,1,j,n,Ak)
end ;
if PrintCode > 0 then begin
writeln ;
writeln('Original times Inverse (by column):') ;
writeln ;
vOUT (pID, n)
end ;
{ Try to Restore Original }
vSGEFA (aID, lda, n, IPvt, InfoCode) ;
if InfoCode = 0 then begin
vSGEDI (aID, lda, n, IPvt, Det, Work, JobCode) ;
if PrintCode > 0 then begin
writeln ;
writeln('Inverse of Inverse (by column):') ;
writeln ;
vOUT (aID, n)
end
end
else
writeln('Error: Inverse is Singular.') ;
{ Close Virtual Arrays }
vClose (pID) ;
vClose (aaID) ;
vClose (aID) ;
{ Done }
writeln('End of Test.')
end.
{ Copyright (C) 1986 Adam Fritz, 133 Main St., Afton, NY 13730 }